package io;

import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * 缓冲字节输出流的缓冲区的问题
 */
public class BosFlashDemo {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("fos.txt");
        BufferedOutputStream bu = new BufferedOutputStream(fos);
        String sin = "好好学习";
        byte[] bin = sin.getBytes(StandardCharsets.UTF_8);
        bu.write(bin);
        bu.flush();//这个方法可以强制将缓冲区的数据一次性写出
        System.out.println("写出完毕");
        bu.close();
    }
}
